#include <iostream>
#include <string.h>
using namespace std;

char *mystrstr(char *haystack, char *needle)
{
    char *result = NULL;
    int a = 0;
    for (int i = 0; haystack[i] != '\0'; i++)
    {
        int j = 0;
        while (haystack[i + j] != '\0' && needle[j] != '\0' && haystack[i + j] == needle[j])
        {
            j++; 
        }
        if (needle[j] == '\0')
        {
            result = &haystack[i];
            break;
        }
        
        
    }
    return result;
}

int main()
{
    char haystack[20] = "hello world";
    char needle[10] = "world";
    const char *result = mystrstr(haystack, needle);
    if (result != NULL)
    {
        cout << result << endl;
    }
    else
    {
        cout << "NULL" << endl;
    }

    return 0;
}